package com.demo.core.service;

import com.demo.base.model.company.CompanyInfo;
import com.demo.base.model.company.Score;
import com.demo.base.page.IPagableDTO;
import com.demo.core.dao.CompanyInfoDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by jiandandia on 2017/4/6.
 */
@Transactional
@Service
public class CompanyInfoService {
    @Autowired
    private CompanyInfoDao companyInfoDao;

    public CompanyInfo newOrupdateCompanyInfo(CompanyInfo companyInfo) throws Exception {
        return companyInfoDao.newOrupdateCompanyInfo(companyInfo);
    }

    public CompanyInfo getCompanyInfoById(String companyInfoId) throws Exception {
        return companyInfoDao.getCompanyInfoById(companyInfoId);
    }

    public IPagableDTO<CompanyInfo> getCompanyInfoByQuery(String companyName, IPagableDTO pagableDTO) {
        return companyInfoDao.getCompanyInfoByQuery(companyName, pagableDTO);
    }

    public void delteCompanyInfoById(String ids) throws Exception {
        String[] idss = StringUtils.split(ids,',');
        for (String id : idss) {
            companyInfoDao.delteCompanyInfoById(id);
        }
    }
    public Score newCompanyInfoScore(Score score) throws Exception {
        return companyInfoDao.newCompanyInfoScore(score);
    }
    }
